package com.cuit.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface HomeMapper {

    @Select("SELECT COUNT(*) FROM user")
    Integer countTotalUsers();

    @Select("SELECT DATE_FORMAT(create_time, '%Y-%m-%d') AS date, COUNT(*) AS count FROM user GROUP BY DATE(create_time)")
    List<Map<String, Object>> countDailyNewUsers();

    @Select(" SELECT COUNT(*) FROM voice")
    Integer countTotalVoices();

    @Select("SELECT COUNT(*) FROM voice  WHERE DATE(create_time) = CURDATE()")
    Integer countTodayVoices();

    @Select("SELECT DATE_FORMAT(create_time, '%Y-%m-%d') AS date, COUNT(*) AS count FROM voice GROUP BY DATE(create_time)")
    List<Map<String, Object>> countDailyNewVoices();
}
